// C bindings for Zig syscall implementation
// SPDX-License-Identifier: MPL-2.0

#include <stdint.h>
#include <stddef.h>

// Forward declarations for Zig functions
extern uint64_t zig_handle_syscall(
    uint64_t syscall_num,
    uint64_t arg0,
    uint64_t arg1,
    uint64_t arg2,
    uint64_t arg3,
    uint64_t arg4,
    uint64_t arg5,
    void* context
);

extern const char* zig_get_syscall_name(uint64_t num);

typedef struct {
    uint64_t calls;
    uint64_t total_time;
    uint64_t errors;
} syscall_stats_t;

extern syscall_stats_t zig_get_syscall_stats(void);

// C wrapper functions for Rust integration
uint64_t c_handle_syscall(
    uint64_t syscall_num,
    uint64_t arg0,
    uint64_t arg1,
    uint64_t arg2,
    uint64_t arg3,
    uint64_t arg4,
    uint64_t arg5,
    void* context
) {
    return zig_handle_syscall(syscall_num, arg0, arg1, arg2, arg3, arg4, arg5, context);
}

const char* c_get_syscall_name(uint64_t num) {
    return zig_get_syscall_name(num);
}

syscall_stats_t c_get_syscall_stats(void) {
    return zig_get_syscall_stats();
}

// Architecture-specific entry points
#ifdef __x86_64__
void syscall_entry_x86_64(void* regs, void* context) {
    // This would be called from assembly syscall entry point
    // Extract arguments from registers and call zig_handle_syscall
    // TODO: Implement register extraction and result setting
}
#endif

#ifdef __aarch64__
void syscall_entry_aarch64(void* regs, void* context) {
    // ARM64 syscall entry
    // TODO: Implement for ARM64
}
#endif

#ifdef __riscv
void syscall_entry_riscv64(void* regs, void* context) {
    // RISC-V syscall entry
    // TODO: Implement for RISC-V
}
#endif